<?php
	include_once('config.php');
	include_once('Connect_pdo.php');
	extract($_GET);
	$return ="";
	if($action=="get"){
		$query = $con->prepare("select cr.*, n.nom as nom, n.prenom as prenom from compterendu1 cr, nomade n where etat=0 
			AND n.idNomade=cr.idNomade");
		$ids;
		$i=0;
		if($query->execute()){
			$count = $query->rowCount();
			$query->setFetchMode(PDO::FETCH_OBJ);
			if($count > 0){
				while($line = $query->fetch()){
					$return[] = array(
						"id"=> $line->idCompteRendu,
						"designation"=> $line->designation,
						"description"=> $line->description,
						"idNomade" => $line->idNomade,
						"etat" => $line->etat,
						"nom" => $line->nom,
						"prenom" => $line->prenom			
						);
					$i++;
				}
				$sql = "UPDATE compterendu1 
				SET etat=-1
				WHERE etat=0";
				$q = $con->prepare($sql);
				$q->execute();
			}
			//echo $ids;
		}
		echo json_encode($return);
	}